import Vue from "vue";
import VueRouter from "vue-router";

// 路由数据
import routes from "./routes";

Vue.use(VueRouter);

// 导出路由 在 main.js 里使用
const router = new VueRouter({
  routes
  // mode:'history'
});

//跳转页面以后回到页面顶部
router.afterEach((to, from, next) => {
  if (to.name != "loading") {
    let forward = {
      name: to.name,
      query: to.query
    };
    localStorage.setItem("forward", JSON.stringify(forward));
  }
  window.scrollTo(0, 0);
});
export default router;
